package com.automannn.seataSamples.stock.controller;

import com.automannn.seataSamples.api.dto.CommodityDTO;
import com.automannn.seataSamples.api.response.ObjectResponse;
import com.automannn.seataSamples.stock.service.IStockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author automannn
 * @Date 2022/3/24
 * @Description 前端控制器
 */
@RestController
@RequestMapping("/stock")
@Slf4j
public class StockController {

    @Autowired
    private IStockService stockService;

    @PostMapping("dec_stock")
    public ObjectResponse decreaseStock(CommodityDTO commodityDTO){
        log.info("扣减库存:{}",commodityDTO);
        return stockService.decreaseStock(commodityDTO);
    }
}
